package com.cyms.modules.base.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.cyms.modules.base.entity.LineScheduleEntity;
import com.cyms.modules.base.service.LineScheduleService;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.cyms.common.utils.PageUtils;
import com.cyms.common.utils.R;



/**
 * 路线行程
 *
 * @author low
 * @email tolower@foxmail.com
 * @date 2018-12-05 22:19:21
 */
@RestController
@RequestMapping("base/lineschedule")
public class LineScheduleController {
    @Autowired
    private LineScheduleService lineScheduleService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("base:lineschedule:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = lineScheduleService.queryPage(params);

        return R.ok().put("page", page);
    }
    /**
     * 列表
     */
    @RequestMapping("/selectlist")
    public R selectlist(@RequestParam Map<String, Object> params){
    	String lineId=(String) params.get("lineId");
        List<LineScheduleEntity> list=lineScheduleService.selectList(new EntityWrapper<LineScheduleEntity>()
        		.eq(StringUtils.isNotBlank(lineId), "line_id",lineId));

        return R.ok().put("list", list);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("base:lineschedule:info")
    public R info(@PathVariable("id") Long id){
			LineScheduleEntity lineSchedule = lineScheduleService.selectById(id);

        return R.ok().put("lineSchedule", lineSchedule);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("base:lineschedule:save")
    public R save(@RequestBody LineScheduleEntity lineSchedule){
			lineScheduleService.insert(lineSchedule);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("base:lineschedule:update")
    public R update(@RequestBody LineScheduleEntity lineSchedule){
			lineScheduleService.updateById(lineSchedule);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("base:lineschedule:delete")
    public R delete(@RequestBody Long[] ids){
			lineScheduleService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }

}
